import {getChatExpReq, getVodExpReq} from "../apis/goApis";
import LocalStorageService from "../utils/LocalStorageService";
import {handleResp} from "../utils/commonfunc";
import {Toast} from "antd-mobile";
import React from 'react'
const uid = LocalStorageService.get('userid');
export const exp = {

    state: {
        exp: 0,
    },

    reducers: {

    },

    effects: (dispatch) => ({
        async doGetVodExp(payload, rootState) {
            const resp = await getVodExpReq({uid,})
            handleResp(resp, dispatch, (data) => {
                const addExp = data.ok.addexp

                if (addExp > 0) {
                    const info = <div>
                        <p>观看视频</p>
                        <p>经验+{addExp}</p>
                    </div>
                    Toast.info(info, 1)
                }
            })
        },

        async doGetChatExp(payload, rootState) {
            const resp = await getChatExpReq({uid,})
            handleResp(resp, dispatch, (data) => {
                const addExp = data.ok.addexp

                if (addExp > 0) {
                    const info = <div>
                        <p>发言成功</p>
                        <p>经验+{addExp}</p>
                    </div>
                    Toast.info(info, 1)
                }
            })
        }
    })
}
